package A_sort;

public class A_SelectSort {
    /**
     * 选择排序
     * 时间复杂度 O(N^2) O(big o the worst situation)  Θ(big theta average situation) Ω(big omega the best situation)
     * 空间复杂度O(1)
     */
    public static void selectSort(int [] arr){
        if (arr.length<2||arr==null){
            return;
        }
        for (int i = 0; i < arr.length-1; i++) {
            int minIndex = i;
            for (int j = i+1; j < arr.length; j++) {
                if (arr[j]<arr[i]){
                    minIndex = j;
                    Swap.swap(arr,i,j);
                }
            }
        }
    }

}
